package com.hu.wc

import org.apache.flink.api.scala._

/**
 * @Author: hujianjun
 * @Create Date: 2020/11/6 17:38
 * @Describe:
 */
object WordCountBatch {
  def main(args: Array[String]): Unit = {

    val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment
    val filePath: String = "D:\\hjj\\I\\ideaWorkSpace\\hu\\flink-scala-learn\\flink-learn\\src\\main\\resources\\data\\wc.txt"
    val textDS: DataSet[String] = env.readTextFile(filePath)

    //此时如果不导入隐式转换包会报错
    textDS.flatMap(_.split(" "))
      .map((_, 1))
      .groupBy(0)
      .sum(1).print()
  }

}
